using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using EditeurSyntaxiqueVocal.ConversionZFrEntreEnu;
using TextEditor.Document;

namespace EditeurSyntaxiqueVocal.Forms
{
    public partial class FormEditorSimple : Form
    {
        private MainForm mainForm;
        public FormEditorSimple(MainForm mainForm)
        {
            InitializeComponent();
            editeurText1.Document.HighlightingStrategy =
                    HighlightingManager.Manager.FindHighlighter("Z");
            this.mainForm = mainForm;
            Owner = mainForm;            
        }

        public new void Show ()
        {
            MainForm.CommunicationForm.Owner = this;
            base.Show();
        }

        public new void Hide()
        {
            try
            {
                MainForm.CommunicationForm.Owner = mainForm;
            }
            catch
            {
            }
            base.Hide();
        }

        private void toolStripButton1_Click(object sender, EventArgs e)
        {
            ConversionZFrEnu cv =
                new ConversionZFrEnu(editeurText1.ActiveTextAreaControl.TextArea.Document.TextContent,
                                     TypeConversionZ.Enu);
            cv.MotEntier = true;
            editeurText1.ActiveTextAreaControl.TextArea.Document.TextContent = cv.Converter();
            editeurText1.ActiveTextAreaControl.TextArea.Invalidate();
        }

        private void toolStripButton2_Click(object sender, EventArgs e)
        {
            ConversionZFrEnu cv =
                            new ConversionZFrEnu(editeurText1.ActiveTextAreaControl.TextArea.Document.TextContent,
                                                 TypeConversionZ.Fr);
            cv.MotEntier = true;
            editeurText1.ActiveTextAreaControl.TextArea.Document.TextContent = cv.Converter().Replace("\r\n\r\n", "\r\n");
            editeurText1.ActiveTextAreaControl.TextArea.Invalidate();
        }       

        private void hauteToolStripMenuItem_Click(object sender, EventArgs e)
        {
            hauteToolStripMenuItem.Checked = true;
            normalToolStripMenuItem.Checked = false;
            Owner = mainForm;
            MainForm.CommunicationForm.Owner=this;
        }

        private void normalToolStripMenuItem_Click(object sender, EventArgs e)
        {
            hauteToolStripMenuItem.Checked = false;
            normalToolStripMenuItem.Checked = true;
            Owner = null;
            MainForm.CommunicationForm.Owner = mainForm;
        }
    }
}